<template>
  <div>
    这是首页
    <el-button @click="testInject">testInject</el-button>
    <el-button @click="loginOut">退出</el-button>
    <el-button @click="testReq" class="mt-5">testReq</el-button>
    <div v-for="(item,index) in taskmgrListData" :key="index">
      <div>任务名：{{item.taskName}}</div>
    </div>
    <!--{{taskmgrListData}}-->
  </div>
</template>

<script>
  import {setToken, removeToken} from '@/utils/auth'

  export default {
    head() {
      return {
        title: "课程列表",
        // vue-meta利用hid确定要更新meta
        meta: [
          {name: "description", hid: "description", content: "set page meta"}
        ],
        link: [{rel: "favicon", href: "favicon.ico"}]
      };
    },
    created() {
      // console.log("created")
      // console.log(process.env)
      // this.testReq();
    },
    mounted() {
      this.testReq();
    },
    beforeDestroy() {
      console.log("beforeDestroy")
    },
    //服务器请求
    async asyncData({$axios, params, error}) {
      const reqData = await $axios({
        url: "rxdrepairsaas-labcenter/taskmgr/list",
        method: "post"
      })
      console.log("reqData", reqData);
      return{
        taskmgrListData:reqData.data,
      }
    },
    data() {
      return {
        goods: []
      }
    },
    methods: {
      testReq() {
        this.$axiosReq({
          url: 'rxdrepairsaas-labcenter/taskmgr/list',
          method: 'post', bfLoading: true,
        }).then(res => {

        })
      },
      loginOut() {
        removeToken();
        this.$router.push('/login?redirect=/')
      },
      testInject() {
        console.log(this.$envConfig);
      }
    }
  }
</script>
